/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.kallsonys.session;

import com.kallsonys.dao.ParameterDAO;

import com.kallsonys.service.Parameter;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import javax.ejb.Stateless;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.sql.DataSource;


/**
 *
 * @author allan
 */
@WebService(serviceName = "ParameterService")
@Stateless()
public class Parameters {

    private ParameterDAO dao;
    @Resource(mappedName = "jdbc/OMS", type = DataSource.class)
    DataSource dsOMS;

    @PostConstruct
    void postConstruct() {
        dao = new ParameterDAO(dsOMS);
    }
    
    
    public List<Parameter> getAllParameter(@WebParam(name = "dummy") boolean dummy) throws Exception {
        List<Parameter> item = null;
        try {

            item = dao.getParameters();
        } catch (Exception ex) {
            throw new Exception(ex.getMessage());
        }

        return item;
    }
    
    
    public Parameter getParameterByName(@WebParam(name = "name") String name) throws Exception {
        Parameter item = null;
        try {

            item = dao.getParameterByName(name);
        } catch (Exception ex) {
            throw new Exception(ex.getMessage());
        }

        return item;
    }
}
